//
//  TableViewCell.m
//  UUChartView
//
//  Created by shake on 15/1/4.
//  Copyright (c) 2015年 uyiuyao. All rights reserved.
//

#import "TableViewCell.h"
#import "DVLineChartView.h"//折线图类
@interface TableViewCell ()<DVLineChartViewDelegate>
{
    NSIndexPath *path;
    NSMutableArray *xArr;
    NSMutableArray*oArr;
    NSMutableArray *tArr;
    NSMutableArray*oArr1;
    NSMutableArray *tArr1;
}
@end

@implementation TableViewCell

//初始化设置数据源以及视图
- (void)initWithXNumArr:(NSMutableArray *)xNumArr oneNumArr:(NSMutableArray *)oneNumArr twoNumArr:(NSMutableArray *)twoNumArr oneNumArr1:(NSMutableArray *)oneNumArr1 twoNumArr1:(NSMutableArray *)twoNumArr1 indexPath:(NSIndexPath *)indexPath{
    xArr = xNumArr;
    oArr = oneNumArr;
    tArr = twoNumArr;
    oArr1 = oneNumArr1;
    tArr1 = twoNumArr1;
    [self showDVLine];
   
}
//初始化折线图
- (void)showDVLine{
    
    DVLineChartView *ccc = [[DVLineChartView alloc] init];
    [self addSubview:ccc];
    
    ccc.yAxisViewWidth = 40;
    ccc.xAxisTextGap = 20;
    
    CGFloat maxValue1 = [[oArr valueForKeyPath:@"@max.floatValue"] floatValue];
    CGFloat maxValue2 = [[tArr valueForKeyPath:@"@max.floatValue"] floatValue];
    CGFloat maxValue = MAX(maxValue1, maxValue2);
    
    ccc.numberOfYAxisElements = maxValue;
    
    ccc.delegate = self;
    ccc.pointUserInteractionEnabled = NO;
    ccc.numberOfYAxisElements = 5;
    
    ccc.yAxisMaxValue = maxValue;
    
    ccc.pointGap = 80;
    
    ccc.showSeparate = YES;
    ccc.separateColor = [UIColor blackColor];
    
    ccc.textColor = [UIColor blackColor];
    ccc.backColor = [UIColor whiteColor];
    ccc.axisColor = [UIColor colorFromHexCode:@"#e4e4e4"];
    ccc.separateColor = [UIColor grayColor];
    ccc.textFont = [UIFont systemFontOfSize:8];
    ccc.xAxisTitleArray = xArr;
    
    
    ccc.frame = CGRectMake(0, 70, EMM_WIDTH - 20, 300);
    

    DVPlot *plot = [[DVPlot alloc] init];
    plot.pointArray = oArr;
    
    plot.lineColor = [UIColor colorFromHexCode:@"#143963"];
    plot.pointColor = [UIColor colorFromHexCode:@"#143963"];
    plot.chartViewFill = NO;
    plot.withPoint = YES;
    plot.buttonColor = [UIColor colorFromHexCode:@"#143963"];
    [ccc addPlot:plot];
    
    DVPlot *plot1 = [[DVPlot alloc] init];
    plot1.pointArray = tArr;
    plot1.lineColor = [UIColor colorFromHexCode:@"#a9575d"];
    plot1.pointColor = [UIColor colorFromHexCode:@"#a9575d"];
    plot1.chartViewFill = NO;
    plot1.withPoint = YES;
    plot1.buttonColor = [UIColor colorFromHexCode:@"#a9575d"];
    [ccc addPlot:plot1];
    
    [ccc draw];
}
@end
